package test;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

import execution.Main;
public class eightyPercentage {
	public static void main(String[] args) throws IOException{
		int nbr =0;
		double percentage = 0;
		
		
		
		for (int linenum=0; linenum<60; linenum++) {
			Scanner scan = new Scanner(new File("src/db.txt"));
			FileWriter out = new FileWriter(new File("src/testdata.txt"));
			args = new String[1];
			
			String line=null;
			int index=0;
			while (scan.hasNextLine()) {
				String ln = scan.nextLine();
				if (index++ != linenum) {
					out.write(ln+"\n");
				} else {
					line = ln;
				}			
			}
			out.flush();
	
			scan = new Scanner(new File("src/testdata.txt"));

			String first = line.split(" ")[0];
			double realEffort = Double.valueOf((first.split(",")[16]));
			args[0] = first;
			Main.main(args);
			double estEffort = Main.effort/730.484398;
			double inRange = estEffort / realEffort;

			if(inRange > 0.7){
				percentage++;
			}
			nbr++;
				
		}
		System.out.println("sucess rate in percentage :" + percentage/nbr);
		System.out.println("percentage :" + percentage);
		System.out.println("number of projects :" + nbr);
	}
}
